<?php

namespace App\Jobs\user;

use App\Jobs\Job;
use App\Models\User;
use Illuminate\Support\Facades\Log;

class RegisterToSms extends Job
{

    // php artisan queue:work redis --queue=RegisterToSms --tries=3
    const QUEUE_NAME = 'RegisterToSms{queue}';

    private $userEmail;
    private $userMobile;


    public function __construct($userEmail,$userMobile)
    {
        $this->userEmail = $userEmail;
        $this->userMobile = $userMobile;
    }

    /**
     * @throws \Symfony\Component\Mailer\Exception\TransportExceptionInterface
     */
    public function handle()
    {
        $welcomeMsg    = 'congratulations to '. $this->userMobile;
        $initAccount   = 'your account is : '. $this->userEmail;
        $initPass      = 'your init password is : '.User::INIT_PASSWORD;
        $data          = compact('welcomeMsg','initPass','initAccount');
        sendEmail(config('blogConfig.from_mail'), $this->userEmail, implode('<br/>',$data),'register email','blog');
//        sendEmail('2571491957@qq.com','yty16601121756@163.com',implode('<br/>',$this->data));

        //todo send sms
        $smsUrl = config('blogConfig.sms_url');
    }

    public function fail($exception = null)
    {
        Log::info($exception);
    }
}